package com.lemurian.bankdata.exceptions;

import com.lemurian.bankdata.lite.enums.BankDataError;

public class BankDataException extends RuntimeException {

    BankDataError err;
    Object[] errData;
    String msg;

    public BankDataException(BankDataError error, Object... errdata) {
        this.err = error;
        this.errData = errdata;
    }

    public BankDataException(String msg, BankDataError error, Object... errdata) {
        this(error, errdata);
        this.msg = msg;
    }

    public BankDataError getError() {
        return err;
    }

    @Override
    public String getMessage() {
        if (msg != null) {
            try {
                return String.format(msg, errData);
            } catch (Exception ex) {
                ex.printStackTrace();
                return msg;
            }
        } else {
            return getError().name();
        //retrieve from properties.
        }
    }

    public String getUserMessage() {
        return null;
    }

}